package com.zzy.servicebase.handle;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @Author KAZU
 * @Date 2023/1/8 7:41
 * @Version 1.0
 */
@SuppressWarnings({"all"})
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
	
//	private static final Logger LOGGER = LoggerFactory.getLogger(MyMetaObjectHandler.class);
	
	@Override
	public void insertFill(MetaObject metaObject) {
//		LOGGER.info("insertFill");
		System.out.println("==============================insertFill==============================");
		//属性名称，不是字段名称
		this.setFieldValByName("gmtCreate", new Date(), metaObject);
		this.setFieldValByName("gmtModified", new Date(), metaObject);
	}
	
	@Override
	public void updateFill(MetaObject metaObject) {
//		LOGGER.info("updateFill");
		System.out.println("==============================updateFill==============================");
		this.setFieldValByName("gmtModified", new Date(), metaObject);
	}
}
